from django.urls import path, include

from rest_framework.routers import DefaultRouter

from sqtp import views

router = DefaultRouter()
# 注册路由，prefix是'requests'
# 以 r 或 R 开头的字符串，表示“原样保留”字符串里的所有字符，不把反斜杠 \ 作为转义符
router.register(r'requests', views.RequestViewSet)
router.register(r'steps', views.StepViewSet)
router.register(r'configs', views.ConfigViewSet)
router.register(r'cases', views.CaseViewSet)
router.register(r'projects', views.ProjectViewSet)
router.register(r'envs', views.EnvironmentViewSet)
router.register(r'plans', views.PlanViewSet)

urlpatterns = [
    # path("request/", views.request_list),
    # path("request_detail/<int:_id>",views.request_detail)
    path('', include(router.urls)),
    path('users/', views.user_list),
    path('users/<int:pk>', views.user_detail),
    path('register/', views.register),
    path('login/', views.login),
    path('logout/', views.logout),
    path('current_user/', views.current_user),
    # as_view()把类视图转为函数视图
    path('upload/<str:filename>/', views.FileUploadView.as_view()),
]
